Week 2

Matrix Multiplication in Python w/NumPy


In [14]:
import numpy as np
x = np.matrix( "2 4 5; 3 4 5")        # Can use either format
y = np.matrix( ((5,10), (10,20), (20,50)) )

In [15]:
x


Out[15]:
matrix([[2, 4, 5],
        [3, 4, 5]])

In [16]:
y


Out[16]:
matrix([[ 5, 10],
        [10, 20],
        [20, 50]])

In [17]:
x * y


Out[17]:
matrix([[150, 350],
        [155, 360]])

Some new notation


In [ ]: